<script setup>
  import { onMounted, ref } from 'vue';
  // 局部自定义指令
  // https://cn.vuejs.org/guide/reusability/custom-directives.html
  defineOptions({name: ''});
  const props = defineProps({});
  const emits = defineEmits(['on-ok']);
  onMounted(() => {});

  const inputValue = ref('');

  // 局部自定义指令，更改为全局注册指令，模式一
  // const vFocus = {
  //   mounted: (el) => {
  //     console.log('el', el);
  //     return el.focus()
  //   }
  // }

  // 子组件暴露
  defineExpose({});

</script>

<template>
 <div>
    自动获取焦点
    <el-input v-focus v-model="inputValue" style="width: 240px" placeholder="请输入" />
  </div>
</template>

<style lang="less" scoped>
div {
  cursor: pointer;
}
</style>
